package com.bible.fire.pad.activity.surface;
/**
 * 主界面
 */

import java.util.ArrayList;
import java.util.HashMap;

import com.bible.fire.R;
import com.bible.fire.local.NetworkManager;
import com.bible.fire.pad.activity.BaseActivity;
import com.bible.fire.pad.activity.aspect.BDGPSLocateActivity;
import com.bible.fire.pad.activity.aspect.FileBrowserActivity;
import com.bible.fire.pad.activity.aspect.GraphBaiduMapActivity;
import com.bible.fire.pad.activity.aspect.TestActivity;
import com.bible.test.common.activity.webview.MyBrowser;
import com.bible.test.pad.activity.gridview.TestPullRefreshGridView;
import com.bible.test.pad.activity.viewpager.TestFragmentPager;

import android.content.Intent;
import android.os.Bundle;

import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class DesktopActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView( R.layout.activity_gridview );
        GridView gridview = (GridView)findViewById(R.id.GridView);
        ArrayList<HashMap<String, Object>> menuList = new ArrayList<HashMap<String, Object>>();
        for( int i = 0; i < mTexts.length; i++ ){
        	HashMap<String, Object> map = new HashMap<String, Object>();
        	map.put("ItemImage", mImages[i]);
        	map.put("ItemText", mTexts[i]);       	
        	menuList.add( map );
        }
        SimpleAdapter saMenuItem = new SimpleAdapter(this, 
        		menuList, //数据源 
      		  R.layout.activity_gridviewitem, //xml实现 
      		  new String[]{"ItemImage","ItemText"}, //对应map的Key 
      		  new int[]{R.id.ItemImage,R.id.ItemText});  //对应R的Id 

      		//添加Item到网格中 
      		gridview.setAdapter(saMenuItem);
      		gridview.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
					Intent intent = new Intent(DesktopActivity.this, mActivities[arg2]);
					startActivity(intent);
				}
      			
      		});
      		NetworkManager.checkNetwork( this );
    }
    
    String mTexts[] = {
    	"测试","浏览器","当前位置","下拉刷新Grid","Fragment Pager","画线地图", "文件浏览"
    };
    
    int mImages[] = {
    	R.drawable.icon_cs, R.drawable.browser, R.drawable.icon_locate,R.drawable.pull_refresh_gridview,
    	R.drawable.google_docs, R.drawable.maps, R.drawable.folder
    };
    
    Class<?> mActivities[] = {
        TestActivity.class, MyBrowser.class, BDGPSLocateActivity.class,TestPullRefreshGridView.class,
        TestFragmentPager.class, GraphBaiduMapActivity.class, FileBrowserActivity.class
    };
}
